API Documentation
Public Member Functions | Public Attributes | List of all members
nkMaths::Rectangle Class Reference

Represents a 2D rectangle. More...

Public Member Functions

 Rectangle ()=default
 
 Rectangle (float x, float y, float width, float height)
 
bool pointInside (Point point) const
 
Rectangle operator+ (const Rectangle &other)
 

Public Attributes

float _x = 0.f
 The x coordinate of the origin. Starts as the bottom left.
 
float _y = 0.f
 The y coordinate of the origin. Starts as the bottom left.
 
float _width = 0.f
 The full width of the rectangle.
 
float _height = 0.f
 The full height of the rectangle.
 

Detailed Description

Represents a 2D rectangle.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

nkMaths::Rectangle::Rectangle ( )
default

Default constructor.

◆ Rectangle() [2/2]

nkMaths::Rectangle::Rectangle ( float  x,
float  y,
float  width,
float  height 
)

Constructor.

Parameters
xThe x component of the origin.
yThe y component of the origin.
widthThe rectangle width.
heightThe rectangle height.

Member Function Documentation

◆ pointInside()

bool nkMaths::Rectangle::pointInside ( Point  point) const

Checks if a point is inside the rectangle.

Parameters
pointThe point to check against the rectangle.
Returns
If the point is inside (true) or not (false).

◆ operator+()

Rectangle nkMaths::Rectangle::operator+ ( const Rectangle other)

Overrides adding rectangles. Conceptually, sum components from the other rectangle with the calling one (origin + other.origin, dimensions + other.dimensions).

Parameters
otherThe rectangle to add.

The documentation for this class was generated from the following file: